package com.chenzouquan.commentline;

import com.chenzouquan.service.FileChangeService;

import java.util.Scanner;

public class CommandLineInterface {
    private static FileChangeService fileChangeService = new FileChangeService();
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("欢迎━(*｀∀´*)ノ! 使用文件格式转换系统");
        System.out.println("输入1，文件转换功能");
        System.out.println("输入2，查看之前转换文件记录");
        System.out.println("输入exit，退出系统");
        while (true) {
            System.out.print("命令行> ");
            String input = scanner.nextLine();

            if (input.equalsIgnoreCase("exit")) {
                System.out.println("退出命令行界面...");
                break;
            } else {
                //System.out.println("你输入的命令是: " + input);
                switch (input){
                    case "1":
                        // 文件转换
                        System.out.println(">请输入文件路径：");
                        String filePath = scanner.nextLine();
                        System.out.println(">请输入转换文件格式");
                        String format = scanner.nextLine();
                        if(filePath.contains(format)){
                            System.out.println("当前格式为目标格式");
                            break;
                        }
                        String s = fileChangeService.FileChange(filePath, format);
                        if (s == null){
                            System.out.println("文件转换失败");
                        }else {
                            System.out.println("文件转换成功\n>目标路径为："+ s);
                        }
                        break;
                    case "2":
                        //查看记录
                        break;
                }
            }
        }

        scanner.close();
    }
}
